﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Dunnice.BlogIndex.Entity
{
    /// <summary>
    /// 博客作者信息.
    /// </summary>
    public class BlogAuthorInfo
    {
        /// <summary>
        /// 作者名称.
        /// </summary>
        public string AuthorName { get; set; }

        /// <summary>
        /// 博客作者别名.
        /// </summary>
        public string Alias { get; set; }

        private string _serverName;
        /// <summary>
        /// 博客服务器名称(这个名称应该和BlogServerEnum枚举值匹配).
        /// </summary>
        public string ServerName
        {
            get
            {
                return _serverName;
            }
            set
            {
                _serverName = value;
                _serverType = (BlogServerEnum)Enum.Parse(typeof(BlogServerEnum), _serverName, true);
            }
        }

        private BlogServerEnum _serverType;
        /// <summary>
        /// 与ServerName匹配;
        /// </summary>
        public BlogServerEnum ServerType
        {
            get
            {
                return _serverType;
            }
            set
            {
                _serverType = value;
                this._serverName = _serverType.ToString();
            }
        }

        /// <summary>
        /// 博客Url.
        /// </summary>
        public string BlogUrl { get; set; }

        /// <summary>
        /// 其他信息.
        /// </summary>
        public string OtherInfo { get; set; }

        /// <summary>
        /// 分组Id.
        /// </summary>
        public int? GroupId { get; set; }

        /// <summary>
        /// 分组名称
        /// </summary>
        public string GroupName { get; set; }

        public string GetAuthorShowName()
        {
            if (!string.IsNullOrEmpty(Alias))
            {
                return string.Format("{0}({1})", Alias, AuthorName);
            }
            else
            {
                return AuthorName;
            }
        }

    }
}
